<?php
session_start();
$title="แก้ไขการจองห้องพัก";
include ('header-admin.php');
$reserv_id = $_REQUEST['reserv_id'];
$reserv_begin_o = $_GET['reserv_begin_o'];
$reserv_end_o = $_GET['reserv_end_o'];

//fetch userdata
$sql="SELECT reserv_begin,reserv_end,room_id,customer.customer_id,customer.id,reserv_status,reserv_etc,reservation.reserv_gid,extra_bed,customer_name,customer_surname,customer_address,customer_tel,customer_fax,customer_email,customer_group_name,reserv_gdetail ,reservgroup.reserv_gcost
		FROM reservation,customer,reservgroup 
		WHERE reservation.id = customer.id AND reservation.reserv_gid = '$reserv_id' AND reservgroup.reserv_gid = '$reserv_id'
		LIMIT 1";
$result = mysql_query($sql);
//$rs = mysql_fetch_array($result);
while($rs = mysql_fetch_array($result))
{

	$reserv_begin = $rs['reserv_begin'];
	$reserv_end = $rs['reserv_end'];
	$room_id = $rs['room_id'];
	$customer_id = $rs['customer_id'];
	$reserv_status = $rs['reserv_status'];
	$reserv_etc = $rs['reserv_etc'];
	$reserv_gid = $rs['reserv_gid'];
	$extra_bed = $rs['extra_bed'];
	$customer_name = $rs['customer_name'];
	$customer_surname = $rs['customer_surname'];
	$customer_address = $rs['customer_address'];
	$customer_tel = $rs['customer_tel'];
	$customer_fax = $rs['customer_fax'];
	$customer_group_name = $rs['customer_group_name'];
	$customer_email = $rs['customer_email'];
	$reserv_gdetail = $rs['reserv_gdetail'];
	$reserv_gcost = $rs['reserv_gcost'];
	
}

?>
<style>

	.trHeight{
		height:35px;
	}
	
</style>
<div id="center-block" class="main-content">
<img src="img/booking.png"/ id="img-block-content">
<div id="content-title-right">
		<h2>แก้ไขการจองห้องพัก</h2>
		<span class="caption">&nbsp;&nbsp;&nbsp;ใช้สำหรับแก้ไขการจองหัองพักหาดบ้านดินรีสอร์ท</span>
		<span class="right-button">
			<form name="jump" method="POST" action="#">
		   		<input type="text" id="result_cutomer" name="result_cutomer" value="" size="35"/>
		   		<input type="hidden" id="search_cutomer" name="search_cutomer" value=""/>
		   		<input type="button" value="ค้นหาลูกค้า" onClick="JavaScript:searchCustomer();" />
		   </form>
		</span>
	</div>

	<hr><br><br><br><br><br>
			<div id="center-block-right">
				<form action="doEditBooking.php" method="POST" id="booking-form">
				
				<table>
					<tr class="trHeight">
						<td>
							<label for="chkInputDate">ระยะเวลาการพัก </label>
						</td>
						<td>
							<? echo $reserv_begin_o; ?> ถึง <? echo $reserv_end_o; ?>
						</td>
					</tr>
					<tr class="trHeight">
						<td>
							<label for="inputDate">แก้ไข ระยะเวลาการพัก</label>
						</td>
						<td>
							<input type="checkbox" name="chkInputEditDate" id="chkInputEditDate" value="1" size="30" />
						</td>
					</tr>
					<tr class="trHeight editTime" >
						<td>
							<label for="inputDate">ระยะเวลาในการพัก เริ่ม</label>
						</td>
						<td>
							<input type="text" id="fromDate" name="fromDate" class="validate[required,custom[date]] text-input"/>
						</td>
					</tr>	
					<tr class="trHeight editTime" >
						<td>
							<label for="inputDate">สิ้นสุด</label>
						</td>
						<td>
							<input type="text" id="toDate" name="toDate" class="validate[required,custom[date]] text-input"/>
							<input type="hidden" id="inputDate" name="inputDate" value="" size="30" />
				  			<input type="hidden" id="reserv_id" name="reserv_id" value="<?=$reserv_id?>" size="30" />
						</td>
					</tr>		
					<tr class="trHeight night">
						<td>
							<label for="inputDate">จำนวนคืนที่เข้าพัก</label>
						</td>
						<td>
							<span id="perNight"></span>
						</td>
					</tr>
					<tr class="bookfrom2 trHeight">
						<td>
							<label for="customer_name">ห้องพักที่ว่าง</label>
						</td>
						<td>
							<div id="roomlist"></div>
						</td>
					</tr>		
					<tr class="trHeight">
						<td>
							<label for="customer_name">ชื่อ-นามสกุล   ผู้จอง</label>
						</td>
						<td>
							<input type="text" id="customer_name" name="customer_name" value="<?=$customer_name?>" size="30" class="validate[required] text-input"/>
							<input type="text" id="customer_surname" name="customer_surname" value="<?=$customer_surname?>" size="30" class="validate[required] text-input"/>
						</td>
					</tr>
					<tr class="bookfrom2 trHeight">
						<td>
							<label for="customer_id">รหัสบัตรประชาชน</label>
						</td>
						<td>
							<input type="text" id="customer_id" name="customer_id" value="<?=$customer_id?>" size="30" />
						</td>
					</tr>
					<tr class="trHeight">
						<td>
							<label for="customer_type">ประเภทลูกค้า</label>
						</td>
						<td>
							<input type="radio" id="normal" name="customer_type" value="0" onClick="chkCustomerType();" <?if(empty($customer_group_name)) { ?>checked<? } ?> /> ประเภทบุคคล
							<input type="radio" id="group" name="customer_type" value="1" onClick="chkCustomerType();" <?if(!empty($customer_group_name)) { ?>checked<? } ?> /> ประเภทกลุ่ม
						</td>
					</tr>	
					<tr class="trHeight group" <?if(empty($customer_group_name)) { ?>style="display: none;<? }?>">
						<td>
							<label for="customer_group_name">ชื่อกลุ่มที่เข้าพัก</label>
						</td>
						<td>
							<input type="text" id="customer_group_name" name="customer_group_name" value="<?=$customer_group_name ?>" size="30" />
						</td>
					</tr>						
					<tr class="trHeight">
						<td>
							<label for="customer_address">ที่อยู่</label>
						</td>
						<td>
							<textarea name="customer_address" cols="50" rows="3" class="" id="customer_address"><?=$customer_address?></textarea>
						</td>
					</tr>	
					<tr class="trHeight">
						<td>
							<label for="customer_email">E-Mail</label>
						</td>
						<td>
							<input type="text" id="customer_email" name="customer_email" value="<?=$customer_email?>" size="30"/>
						</td>
					</tr>	
					<tr class="trHeight">
						<td>
							<label for="customer_tel">เบอร์โทรศัพท์</label>
						</td>
						<td>
							<input type="text" id="customer_tel" name="customer_tel" value="<?=$customer_tel?>" size="30" class="validate[required,custom[telephone]] text-input" />
						</td>
					</tr>	
					<tr class="trHeight">
						<td>
							<label for="customer_fax">Fax</label>
						</td>
						<td>
							<input type="text" id="customer_fax" name="customer_fax" value="<?=$customer_fax?>" size="30" class="" />
						</td>
					</tr>						
					<tr class="trHeight">
						<td>
							<label for="reserv_gdetail">รายละเอียดอื่นๆ</label>
						</td>
						<td>
							<textarea name="reserv_gdetail" cols="50" rows="3" class="" id="reserv_gdetail"><?=$reserv_gdetail?></textarea>
						</td>
					</tr>																				
				</table>
				<br><br>
				<input type="hidden" value="<?=$reserv_status?>" name="reserv_status" id="reserv_status">
				<p class="submit"><input type="submit" value="เรียบร้อย" /></p>
				</form>
				<br><br>
			</div>
	</div>

<?
include ('footer.php');
?>